package avriServer.command.avriServer;

import java.util.HashMap;

import avriServer.client.NonexistantWaiterException;
import avriServer.client.UnvalidWaiterException;
import avriServer.client.Waiter;
import avriServer.client.Worker;
import avriServer.command.Command;
import avriServer.command.WaiterBuilder;
import avriServer.json.JSONException;
import avriServer.json.JSONObject;
import avriServer.server.Dispatcher;
import avriServer.util.IdentificationException;

public class Connect extends Command implements WaiterBuilder{

	public Connect(JSONObject _jsonObject, HashMap<String, String> _attributes ) throws IdentificationException, NonexistantWaiterException {
		super(_jsonObject, _attributes);
	}

	@Override
	public void execute(Worker _worker) {
		try {
			//this.waiter = new Waiter(this.getCommandAttribute("name"), Dispatcher.generateWaiterSession(), this.getCommandAttribute("cometType"), this.getCommandAttribute("cometName"), _worker);
			Waiter w = new Waiter(this.getAttributes(), this.getCommandAttributes(), _worker);
			Dispatcher.addWaiter(w);
		} catch (UnvalidWaiterException e) {
			e.printStackTrace();
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}
}
